//home模块的仓库
const state = () => ({
    //新闻列表
    newsList:[],
    //轮播图的数据
    bannerList: [],
    //最热文章列表
    hottestShow:[],
    //最关心文章列表
    concernedShow: [],
    //医生（混杂）列表
    allDoctorList:[],
})

//mutations是唯一修改state的地方
const mutations = {
    SETNEWSLIST(state,list){
        state.newsList=list
    },
    SETBANNERLIST(state, bannerList) {
        state.bannerList = bannerList
    },
    SETHOTTEST(state,list){
        state.hottestShow=list
    },
    SETCONCERN(state,list){
        state.concernedShow=list
    },
    SETDOCTORLIST(state,list){
        state.allDoctorList=list
    }
}

//action是用户处理派发action的地方，可以书写异步语句、逻辑的地方
const actions = {
    //获取首页轮播图的数据
    async getBannerList({ commit }) {
        let result = await reqBannerList()
        if (result.code === 200) {
            commit('GETBANNERLIST', result.data)
        }
    }
}

const getters = {}
export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
}